package com.platform.usercenter.service.impl;

import com.platform.common.core.utils.DateUtils;
import com.platform.usercenter.domain.SysOrganizationAdministrator;
import com.platform.usercenter.mapper.SysOrganizationAdministratorMapper;
import com.platform.usercenter.service.ISysOrganizationAdministratorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 组织管理员Service业务层处理
 *
 * @author platform
 * @date 2024-10-24
 */
@Service
public class SysOrganizationAdministratorServiceImpl implements ISysOrganizationAdministratorService {
    @Resource
    private SysOrganizationAdministratorMapper sysOrganizationAdministratorMapper;

    /**
     * 查询组织管理员
     *
     * @param userId 组织管理员主键
     * @return 组织管理员
     */
    @Override
    public SysOrganizationAdministrator selectSysOrganizationAdministratorByUserId(Long userId, Long orgId) {
        return sysOrganizationAdministratorMapper.selectSysOrganizationAdministratorByUserId(userId, orgId);
    }

    /**
     * 查询组织管理员列表
     *
     * @param sysOrganizationAdministrator 组织管理员
     * @return 组织管理员
     */
    @Override
    public List<SysOrganizationAdministrator> selectSysOrganizationAdministratorList(SysOrganizationAdministrator sysOrganizationAdministrator) {
        return sysOrganizationAdministratorMapper.selectSysOrganizationAdministratorList(sysOrganizationAdministrator);
    }

    /**
     * 新增组织管理员
     *
     * @param sysOrganizationAdministrator 组织管理员
     * @return 结果
     */
    @Override
    public int insertSysOrganizationAdministrator(SysOrganizationAdministrator sysOrganizationAdministrator) {
        sysOrganizationAdministrator.setCreateTime(DateUtils.getNowDate());
        return sysOrganizationAdministratorMapper.insertSysOrganizationAdministrator(sysOrganizationAdministrator);
    }

    /**
     * 修改组织管理员
     *
     * @param sysOrganizationAdministrator 组织管理员
     * @return 结果
     */
    @Override
    public int updateSysOrganizationAdministrator(SysOrganizationAdministrator sysOrganizationAdministrator) {
        sysOrganizationAdministrator.setUpdateTime(DateUtils.getNowDate());
        return sysOrganizationAdministratorMapper.updateSysOrganizationAdministrator(sysOrganizationAdministrator);
    }

    /**
     * 批量删除组织管理员
     *
     * @param userIds 需要删除的组织管理员主键
     * @return 结果
     */
    @Override
    public int deleteSysOrganizationAdministratorByUserIds(Long[] userIds) {
        return sysOrganizationAdministratorMapper.deleteSysOrganizationAdministratorByUserIds(userIds);
    }

    /**
     * 删除组织管理员信息
     *
     * @param userId 组织管理员主键
     * @return 结果
     */
    @Override
    public int deleteSysOrganizationAdministratorByUserId(Long userId) {
        return sysOrganizationAdministratorMapper.deleteSysOrganizationAdministratorByUserId(userId);
    }
}
